package entities;

import awe6.core.Entity;
import awe6.interfaces.IKernel;
import nme.Assets;
import nme.display.Bitmap;
import nme.display.BitmapData;
import nme.display.Tilesheet;
import nme.geom.Rectangle;

import nme.geom.Point;
import nme.display.Sprite;

/**
 * ...
 * @author Andrew Ekeren
 */
	
class Bunny extends Entity  {	
	
	
	public var speedX:Float;
	public var speedY:Float;
	public var position:Point;
	public var rotation:Float;
	public var scale:Float;
	public var alpha:Float;
	
	private var _bunnyAsset:Bitmap;
	private var _sprite:Sprite;
	private var _tilesheet:Tilesheet;
	
	
	public function new  ( p_kernel:IKernel ) {
		
		_bunnyAsset = new Bitmap (Assets.getBitmapData ("assets/graphics/wabbit_alpha.png"));
		_kernel.assets.getAsset (
		_sprite = new Sprite ();
		_sprite.addChild (_bunnyAsset);
		
		//_tilesheet = new Tilesheet(_bunnyAsset);
		//_tilesheet.addTileRect(new Rectangle (0, 0, _bunnyAsset.width, _bunnyAsset.height));
		
		super ( p_kernel, _sprite );		
		
		trace ( "Bunny created" );
		
	}
	
	override private function _init():Void  {
		
		super._init();
		// extend here
		
		position = new Point ();
		speedX = Math.random () * 5;
		speedY = (Math.random () * 5) - 2.5;
		scale = 0.3 + Math.random ();
		rotation = 15 - Math.random () * 30;
		
		// TODO push into array
		
	}
	
	public function updateAnim ( _drawList : Array<Float>, _smooth : Bool ):Void {
		
		//_tilesheet.drawTiles(_sprite.graphics, _drawList, _smooth, 
		//	Tilesheet.TILE_SCALE | Tilesheet.TILE_ROTATION | Tilesheet.TILE_ALPHA);
		
	}
	
	override private function _updater ( ?p_deltaTime:Int = 0 ):Void  {
		
		super._updater ( p_deltaTime );
		// extend here
		
	}
	
	override private function _disposer ():Void  {
		
		// extend here
		super._disposer();		
	}
	
}